﻿using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;

namespace StockTools.Model
{
    /// <summary>
    /// 费率设定
    /// </summary>
    public class RateSettingModel : BindableBase
    {
        private decimal buyBrokerageRatio;
        private decimal minBrokerageRatio;
        private decimal stampDuty;
        private decimal minStampDuty;
        private decimal transferMoney;
        private decimal minTransferMoney;
        private decimal buyOtherMoney;
        private decimal sellOtherMoney;

        public RateSettingModel()
        {

        }

        /// <summary>
        /// 佣金
        /// </summary>
        public decimal BuyBrokerageRatio
        {
            get => buyBrokerageRatio;
            set
            {
                SetProperty(ref buyBrokerageRatio, value);
            }
        }
        /// <summary>
        /// 最低佣金
        /// </summary>
        public decimal MinBrokerageRatio { get => minBrokerageRatio; set => SetProperty(ref minBrokerageRatio, value); }
        /// <summary>
        /// 印花税
        /// </summary>
        public decimal StampDuty { get => stampDuty; set => SetProperty(ref stampDuty, value); }
        /// <summary>
        /// 最小印花税
        /// </summary>
        public decimal MinStampDuty { get => minStampDuty; set => SetProperty(ref minStampDuty, value); }
        /// <summary>
        /// 过户费
        /// </summary>
        public decimal TransferMoney { get => transferMoney; set => SetProperty(ref transferMoney, value); }
        /// <summary>
        /// 最低过户费
        /// </summary>
        public decimal MinTransferMoney { get => minTransferMoney; set => SetProperty(ref minTransferMoney, value); }
        /// <summary>
        /// 其他费用（买入）
        /// </summary>
        public decimal BuyOtherMoney { get => buyOtherMoney; set => SetProperty(ref buyOtherMoney, value); }
        /// <summary>
        /// 其他费用（卖出）
        /// </summary>
        public decimal SellOtherMoney { get => sellOtherMoney; set => SetProperty(ref sellOtherMoney, value); }

        public void Read(SettingConfig settingConfig)
        {
            BuyBrokerageRatio = settingConfig.BuyBrokerageRatio;
            MinBrokerageRatio = settingConfig.MinBrokerageRatio;
            StampDuty = settingConfig.StampDuty;
            MinStampDuty = settingConfig.MinStampDuty;
            TransferMoney = settingConfig.TransferMoney;
            MinTransferMoney = settingConfig.MinTransferMoney;
            BuyOtherMoney = settingConfig.BuyOtherMoney;
            SellOtherMoney = settingConfig.SellOtherMoney;
        }
        protected override void OnPropertyChanged(PropertyChangedEventArgs args)
        {
            base.OnPropertyChanged(args);
            var settingConfig = new SettingConfig();

            settingConfig.Save("", this, null);
        }
    }
}